package base.多线程.同步代码.阻塞队列;

import java.util.concurrent.ArrayBlockingQueue;

public class Cooker extends Thread{
    ArrayBlockingQueue<String> queue;
    Cooker(ArrayBlockingQueue<String> queue){
        this.queue = queue;
    }

    @Override
    public void run() {
        int n = 0;
        while(n < 2){
            n++;
            try {
                queue.put("蛋糕");
                queue.put("巧克力");
                queue.put("饼干");
                queue.put("火鸡");
                queue.put("奶酪");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
